class CaesarCipher:
    def __init__(self, shift):
        self.shift = shift

    def encrypt(self, text):
        encrypted_text = ""
        for char in text:
            if char.isalpha():
                shift = self.shift % 26
                start = ord('A') if char.isupper() else ord('a')
                encrypted_text += chr((ord(char) - start + shift) % 26 + start)
            else:
                encrypted_text += char
        return encrypted_text

    def decrypt(self, text):
        return self.encrypt(text)  # 凯撒密码的解密与加密相同，只需反向偏移相同的位数

# 示例使用
if __name__ == "__main__":
    cipher = CaesarCipher(3)
    original_text = "Hello, World!"
    encrypted_text = cipher.encrypt(original_text)
    decrypted_text = cipher.decrypt(encrypted_text)
    
    print("Original:", original_text)
    print("Encrypted:", encrypted_text)
    print("Decrypted:", decrypted_text)